from django.http import JsonResponse
from django.views import View
from housecentapp.models import Cities, Navs


class Cityapis(View):
    def get(self,request,*args,**kwargs):
        navs=Navs.objects.filter(city_id=kwargs["cityid"])
        city = Cities.objects.get(id=kwargs["cityid"])
        data=[]
        for nav in navs:
            data.append({
                "navid":nav.id,
                "width":nav.weight,
                "height":nav.height,
                "img":nav.imgsrc
            })
        return JsonResponse({"city":city.name,"data":data})
    def post(self):
        pass
    def put(self):
        pass
    def petch(self):
        pass
    def delete(self):
        pass